import { Store, createStore } from 'vuex';

const store = createStore<IState>({
    state() {
        return {
            currentUser: undefined,
        };
    },
    mutations: {
        setCurrentUser(state, payload) {
            state.currentUser = payload;
        },
    },
    actions: {
        fetchCurrentUser({ commit, dispatch, state }) {
            // commit("setCurrentUser", {account: "Thyiad"})
        },
    },
});

export interface UserItem extends BaseModel {
    account?: string;
    role?: string;
    name?: string;
    avatar?: string;
    sex?: string;
    phone?: string;
    email?: string;
}

export interface IState {
    currentUser?: UserItem;
}

declare module '@vue/runtime-core' {
    interface ComponentCustomProperties {
        $store: Store<IState>;
    }
}

export default store;
